package com.zjitc;

import com.zaxxer.hikari.HikariDataSource;
import java.sql.Connection;
import java.sql.SQLException;
import javafx.application.Application;
import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/6 14:01
 * @description:
 */
public class App2 {

  public static void main(String[] args) {
    ApplicationContext context=new ClassPathXmlApplicationContext("hikariCP-spring-config.xml");
    DataSource bean=context.getBean(DataSource.class);


    try {
      Connection  connection=bean.getConnection();
      System.out.println(connection);
    } catch (Exception e) {
      e.printStackTrace();
    }

  //  HikariDataSource dataSource=null;
  //
  //try {
  //  dataSource = new HikariDataSource();
  //  dataSource.setUsername("root");
  //  dataSource.setPassword("123456");
  //  dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  //  dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test");
  //
  //  try {
  //    Connection connection = dataSource.getConnection();
  //    System.out.println(connection);
  //  } catch (SQLException e) {
  //    e.printStackTrace();
  //  }
  //
  //}finally {
  //if (dataSource!=null){
  //  dataSource.close();
  //}
  //}


  }
}
